home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++)))) RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWZone - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss #include <time.h> #include <rw/zone.h> ((((aaaabbbbssssttttrrrraaaacccctttt bbbbaaaasssseeee ccccllllaaaassssssss)))) DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn RRRRWWWWZZZZoooonnnneeee is an abstract base class. It defines an interface for time zone issues such as whether or not daylight-saving time is in use, the names and offsets from UTC (also known as GMT) for both standard and daylight- saving times, and the start and stop dates for daylight-saving time, if used. Note that because it is an aaaabbbbssssttttrrrraaaacccctttt base class, there is no way to actually enforce these goals -- the description here is merely the model of how a class derived from RRRRWWWWZZZZoooonnnneeee should act. Most programs interact with RRRRWWWWZZZZoooonnnneeee only by passing an RRRRWWWWZZZZoooonnnneeee reference to an RRRRWWWWTTTTiiiimmmmeeee or RRRRWWWWDDDDaaaatttteeee member function that expects one. RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee is an implementation of the abstract RRRRWWWWZZZZoooonnnneeee interface sufficient to represent U.S. daylight- saving time rules. Three instances of RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee are initialized from the global environment at program startup to represent local, standard, and universal time. They are available via calls to the static member functions RRRRWWWWZZZZoooonnnneeee::::::::llllooooccccaaaallll(((()))), RRRRWWWWZZZZoooonnnneeee::::::::ssssttttaaaannnnddddaaaarrrrdddd(((()))), and RRRRWWWWZZZZoooonnnneeee::::::::uuuuttttcccc(((()))), respectively. See the class RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee for details. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee None EEEExxxxaaaammmmpppplllleeee #include <rw/zone.h> #include <rw/rwtime.h> #include <rw/rstream.h> main(){ RWTime now; cout << now.asString(' ', RWZone::local()) << endl; cout << now.asString("%x %X", RWZone::utc()) << endl; return 0; } EEEEnnnnuuuummmmeeeerrrraaaattttiiiioooonnnnssss enum DstRule { NoDST, NoAm, WeEu }; Used by the static member function ddddssssttttRRRRuuuulllleeee(((()))), described below, and by constructors for classes derived from RRRRWWWWZZZZoooonnnneeee. PPPPaaaaggggeeee 1111 RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++)))) RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++)))) enum StdZone { NewZealand = -12, CarolineIslands, MarianaIslands, Japan, China, Java, Kazakh, Pakistan, CaspianSea, Ukraine, Nile, Europe, Greenwich, Azores, Oscar, Greenland, Atlantic, USEastern, USCentral, USMountain, USPacific, Yukon, Hawaii, Bering }; SSSSttttddddZZZZoooonnnneeee is provided to name the standard time zones. Its values are intended to be passed to constructors of classes derived from RRRRWWWWZZZZoooonnnneeee. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss virtual int ttttiiiimmmmeeeeZZZZoooonnnneeeeOOOOffffffffsssseeeetttt() const = 0; Returns the number of seconds west of UTC for standard time in this zone. The number is negative for zones east of Greenwich, England. virtual int aaaallllttttZZZZoooonnnneeeeOOOOffffffffsssseeeetttt() const = 0; Returns the number of seconds west of UTC for daylight-saving time in this zone. virtual RWBoolean ddddaaaayyyylllliiiigggghhhhttttOOOObbbbsssseeeerrrrvvvveeeedddd() const = 0; Returns TTTTRRRRUUUUEEEE if daylight-saving time is observed for this zone. virtual RWBoolean iiiissssDDDDaaaayyyylllliiiigggghhhhtttt(const struct tm* tspec) const = 0; Returns TTTTRRRRUUUUEEEE if the time and date represented in the ssssttttrrrruuuucccctttt ttttmmmm argument is in the range of daylight-saving time for this zone. The elements of the ttttmmmm argument must all be self-consistent; in particular, the ttttmmmm____wwwwddddaaaayyyy member must agree with the ttttmmmm____yyyyeeeeaaaarrrr, ttttmmmm____mmmmoooonnnn, and ttttmmmm____ddddaaaayyyy members. virtual void ggggeeeettttBBBBeeeeggggiiiinnnnDDDDaaaayyyylllliiiigggghhhhtttt(struct tm*) const = 0; virtual void ggggeeeettttEEEEnnnnddddDDDDaaaayyyylllliiiigggghhhhtttt (struct tm*) const = 0; Return with the ssssttttrrrruuuucccctttt ttttmmmm argument set to the local time that daylight- PPPPaaaaggggeeee 2222 RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++)))) RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++)))) saving time begins, or ends, for the year indicated by the ttttmmmm____yyyyeeeeaaaarrrr member passed in. If daylight-saving time is not observed, the ssssttttrrrruuuucccctttt ttttmmmm members are all set to a negative value. Note that in the southern hemisphere, daylight-saving time ends at an earlier date than it begins. virtual RWCString ttttiiiimmmmeeeeZZZZoooonnnneeeeNNNNaaaammmmeeee() const = 0; virtual RWCString aaaallllttttZZZZoooonnnneeeeNNNNaaaammmmeeee() const = 0; Return the name of, respectively, the standard and daylight-saving time zones represented, such as """"PPPPSSSSTTTT"""" and """"PPPPDDDDTTTT"""". Note that the current date and time have no effect on the return values of these functions. SSSSttttaaaattttiiiicccc PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss static const RWZone& llllooooccccaaaallll(); Returns a reference to an RRRRWWWWZZZZoooonnnneeee representing local time. By default this will be an instance of RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee created with offsets and zone names from the operating system, with U.S. rules for daylight-saving time if observed. This is used as the default argument value for RRRRWWWWDDDDaaaatttteeee and RRRRWWWWTTTTiiiimmmmeeee functions that take an RRRRWWWWZZZZoooonnnneeee. static const RWZone& ssssttttaaaannnnddddaaaarrrrdddd(); Returns a reference to an RRRRWWWWZZZZoooonnnneeee representing standard local time, with no daylight-saving time corrections. By default this is an instance of RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee with offset and zone name from the operating system. static const RWZone& uuuuttttcccc(); Returns a reference to an RRRRWWWWZZZZoooonnnneeee representing UTC (GMT) universal time. static const RWZone* llllooooccccaaaallll(const RWZone*); static const RWZone* ssssttttaaaannnnddddaaaarrrrdddd(const RWZone*); These functions allow the values returned by the other functions above to be set. Each returns the previous value. static constRWDaylightRule* ddddssssttttRRRRuuuulllleeee(DstRule rule = NoAm); PPPPaaaaggggeeee 3333 RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++)))) RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++)))) Returns one of the built-in daylight-saving time rules according to rrrruuuulllleeee. Function ddddssssttttRRRRuuuulllleeee(((()))) is provided for convenience in constructing RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee instances for time zones in which common daylight-saving time rules are obeyed. Currently two such rule systems are provided, NNNNooooAAAAmmmm for the U.S.A. and Canada, and WWWWeeeeEEEEuuuu for most of Western Europe (excluding the U.K.). See RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee for more details. If DDDDssssttttRRRRuuuulllleeee NNNNooooDDDDSSSSTTTT is given, then 0000 is returned. The result of calling ddddssssttttRRRRuuuulllleeee(((()))) is normally passed to the RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee constructor. PPPPaaaaggggeeee 4444